package com.lingjtx.common.core.constant;

// 验证码消息类型
public enum CodeMessage {
    DEFAULT(0, "", RedisConfig.TIMEOUT_SMS_CODE),

    LOGIN(1, "（登录验证码）。该验证码有效时间10分钟", RedisConfig.TIMEOUT_SMS_CODE),

    UPDATE_PASSWORD(2, "（修改密码验证码）。该验证码有效时间10分钟", RedisConfig.TIMEOUT_SMS_CODE),

    MOBILE_BOUND(3, "（手机号码绑定验证码）。该验证码有效时间10分钟", RedisConfig.TIMEOUT_SMS_CODE)

    ;

    private int code;

    private String msg;

    private long time;

    public long getTime() {
        return time;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    CodeMessage(int code, String msg, long time) {
        this.code = code;
        this.msg = msg;
        this.time = time;
    }

    public static CodeMessage codeOf(int code) {
        for (CodeMessage value : CodeMessage.values()) {
            if (code == value.getCode()) {
                return value;
            }
        }
        return DEFAULT;
    }

    @Override
    public String toString() {
        return this.getMsg();
    }
}
